<%--
  Created by IntelliJ IDEA.
  User: pc
  Date: 2020/2/24
  Time: 12:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<!-- JSTL 核心标签库 -->
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<html>
<head>
    <title>首页</title>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">

    <style>
        html body {
            margin: 0;
            padding: 0;
            background-color: #e4e4e4;
        }


        .center {

            height: 89%;
        }

        tr {
            margin: 0;
        }

        td {
            border: 1px solid;
            text-align: center;
            width: 180px;
            height: 30px;
        }

        table {
            margin: 0 auto 0 auto;
            margin-top: 80px;
        }

        .table-th {
            background-color: #cccccc;
        }

        .button {
            position: absolute;
            left: 302px;
            top: 35px;
            width: 150px;
            height: 40px;
            border-radius: 5px;
        }

        .button:hover {
            width: 155px;
            height: 42px;
            background-color: #cccccc;
        }

        .on {
            background-color: #f3f3da;
            padding-bottom: 40px;
            position: absolute;
            text-align: center;
            border: 2px solid #727369;
            top: 40%;
            left: 50%;
            height: 400px;
            width: 400px;
            border-radius: 20px;
            transform: translate(-50%, -50%);
            z-index: 999;
        }

        .sub:hover {
            color: #7985b0;
            width: 110px;
            height: 47px;
        }


        .form-input:hover {
            width: 320px;
            height: 47px;
            border: 4px #64ff6e solid;
            color: #795ebe;
            font-size: 24px;
        }

        input::-webkit-input-placeholder {
            color: #ccc;
        }

        input::-ms-input-placeholder {
            color: #ccc;
        }

        .form-input {
            border: 2px solid #727369;
            width: 300px;
            height: 45px;
            border-radius: 5px;
            margin-top: 30px;
            text-align: center;

        }

        .sub {
            width: 100px;
            height: 45px;
            border: 0;
            border-radius: 5px;
            margin-top: 20px;
            text-align: center;
        }

    </style>

</head>
<body>

<div class="top"><input type="button" value="添加" onclick="add()" class="button"></div>
<div class="center">
    <table>
        <tr class="table-th">
            <td>编号</td>
            <td>姓名</td>
            <td>地址</td>
            <td>电话</td>
            <td>操作</td>
        </tr>

        <c:forEach items="${resumes}" var="resume">
            <tr class="table-tr">
                <td>${resume.id}</td>
                <td>${resume.name}</td>
                <td>${resume.address}</td>
                <td>${resume.phone}</td>
                <td><a href="#" onclick="updatdData('${resume.name}','${resume.address}','${resume.phone}','${resume.id}')">修改</a>/
                    <a href="#" onclick="delData(${resume.id})">删除</a>
                </td>
            </tr>
        </c:forEach>
    </table>
</div>

<div class="on"  hidden="hidden">
    <button onclick="closeWinDow()" style="background-color: #e4e4e4;position: fixed;right: 16px;top: 2px">关闭</button>
    <form id="myForm" action="/index/updata" method="post">

        <input type="text" placeholder="name" id="name" name="name" class="form-input"><br>
        <input type="text" placeholder="address" id="address" name="address" class="form-input"><br>
        <input type="text" placeholder="phone" id="phone" name="phone" class="form-input"><br>
        <input type="hidden"  id="id" name="id" value="0">
        <input type="submit" value="提交" class="sub">
    </form>

</div>


</body>
<script type="text/javascript" src="/js/jquery.min.js"></script>

<script type="text/javascript">

    function add() {
        $("#name").val("");
        $("#address").val("");
        $("#phone").val("");
        $("#id").val("0");
        $(".on").attr("hidden",false);
    }

    function closeWinDow() {
        $(".on").attr("hidden",true);
    }

    function updatdData(name,address,phone,id){
        $("#name").val(name);
        $("#address").val(address);
        $("#phone").val(phone);
        $("#id").val(id);
        $(".on").attr("hidden",false);
    }

    function delData(id) {

        let b = confirm("确定要删除数据吗？");

        if (b){
            window.location.href="/index/delData?id="+id;
            return true;
        }else {
            return false;
        }

    }





</script>
</html>
